package com.algorithm.threehundred2fourhundred;

/**
 * @author: tzj
 * @create: 2021-05-27
 **/
public class IsSubsequence_392 {

    public static void main(String[] args) {
        String s = "abcf", t = "ahbgdc";
        System.out.println(isSubsequence(s, t));
    }

    public static boolean isSubsequence(String s, String t) {
        int n = s.length(), m = t.length();
        int i = 0, j = 0;
        while (i < n && j < m) {
            if (s.charAt(i) == t.charAt(j)) {
                i++;
            }
            j++;
        }
        // 当i的长度和j的长度一样，表明i的字符在b中都有
        return i == n;
    }
}
